package com.atom.app.mvvm

import com.atom.app.mvvm.net.*
import com.atom.app.mvvm.net.bean.AuthorResult
import com.atom.app.mvvm.net.bean.LoginResult
import com.atom.app.mvvm.net.bean.TaskDetail
import com.atom.app.mvvm.net.bean.TaskInfo
import com.atom.app.mvvm.net.bean.TokenResult
import com.atom.app.mvvm.net.bean.UserInfo
import com.atom.app.mvvm.net.dto.LoginUser
import io.reactivex.rxjava3.core.Observable
import retrofit2.http.*

interface AppNetApi {
    @POST("/system/login")
    fun loginJson(
        @Body body: LoginUser
    ): Observable<BaseResponse<LoginResult>>

    @POST("/system/refresh")
    suspend fun refreshToken(
        @Body token: TokenResult
    ): BaseResponse<TokenResult>

    @GET("/system/list")
    fun listAuthor(): Observable<BaseResponse<List<AuthorResult>>>

    // userName=admin&passWord=123&adminFlag=admin
    @POST("/login")
    @FormUrlEncoded
    fun login(
        @Field("username") name: String?,
        @Field("password") passWord: String?
    ): Observable<BaseResponse<Unit>>

    @POST("/api/getUserInfo")
    @FormUrlEncoded
    fun getUserInfo(@Field("userName") name: String = "admin"): Observable<BaseResponse<List<UserInfo.Data>>>

    @POST("/api/updateUser")
    @FormUrlEncoded
    fun updateUserInfo(@Field("updateUserInfo") updateUserInfo: String): Observable<BaseResponse<Unit>>

    @POST("/api/deleteUser")
    @FormUrlEncoded
    fun deleteUser(@Field("deleteUserInfo") deleteUserInfo: String): Observable<BaseResponse<Unit>>

    @POST("/api/getUserInfo")
    fun getUserInfoList(): Observable<BaseResponse<List<UserInfo.Data>>>

    @POST("/api/getAllTask")
    @FormUrlEncoded
    fun getAllTask(
        @Field("myName") myName: String?,
        @Field("trueName") trueName: String?,
        @Field("beginTime") beginTime: String? = null,
        @Field("endTime") endTime: String? = null,
        @Field("schemeName") schemeName: String? = null,
        @Field("schemeCompany") schemeCompany: String? = null,
        @Field("childCompany") childCompany: String? = null
    ): Observable<BaseResponse<List<TaskInfo.Data>>>


    @POST("/api/getTaskDetail")
    @FormUrlEncoded
    fun getTaskDetail(
        @Field("taskId") taskId: Int?
    ): Observable<BaseResponse<TaskDetail.Data>>

    @POST("/api/getRoleInfo")
    @FormUrlEncoded
    fun getRoleInfo(): Observable<BaseResponse<TaskDetail.Data>>


}
